$(function(){
  tinymce.init({
    selector: '#content',
    language:'zh_CN',//注意大小写
});


    $.ajax({
        type: 'get',
        url: 'http://localhost:8080/api/v1/admin/category/list',
        headers:{
          Authorization:localStorage.getItem('token')
         },
        success: (backData) => {
      let res=  template('temp',backData)
      $('.category').html(res)
        },
      })

    let ids= window.location.search.split('=')[1]
$.ajax({
  type: 'get',
  url: 'http://localhost:8080/api/v1/admin/article/search',
  headers:{
    Authorization:localStorage.getItem('token')
  },
  data: {id:ids},
  success: (backData) => {
        // console.log(backData);
$('#inputTitle').val(backData.data.title)
$('.article_cover').attr('src',backData.data.cover)
$('#categoryId').val(backData.data.categoryId)
$('#dateinput').val(backData.data.date)
$('#content').text(backData.data.content)
  }
})
$('.btn-edit').on('click',function(e){
e.preventDefault()
let f=new FormData($('form')[0])
let ids= window.location.search.split('=')[1]
f.append('id',ids)
let content = tinyMCE.editors['content'].getContent();
f.append('content', content);
$.ajax({
  type: 'post',
  url: 'http://localhost:8080/api/v1/admin/article/edit',
  headers:{
    Authorization:localStorage.getItem('token')
   },
  data: f,
  
  contentType:false,
  processData:false,
  success: (backData) => {
    window.location.href='./article_list.html'
  },
})
})
})